function Swiper(el,opation){
    this.el = document.querySelector(el)
    this.page =this.el.querySelectorAll('ul li')
    this.t = null
    this.num = 1
    this.init()
}
Swiper.prototype.init = function(){
    //公共空间可以放很多属性
    //轮播图切换图片
    this.changeimg()
    this.overstop()
    // this.overmove()
}
Swiper.prototype.changeimg = function(){
   //定时器
//    let num = 1
   this.t =setInterval(()=>{
    //获取所有图片
    this.num++
    if(this.num>6) this.num=1
    let imgs1 = this.el.querySelector('img')
    // console.log(img)
    imgs1.src = `./imgs/img${this.num}.jpg`
     //同步圆圈
     //将带有圆圈的active去掉
     this.el.querySelector('ul li.active').className = ''
     //给所有li添加active属性
     this.el.querySelectorAll('ul li')[this.num-1].className = 'active'
    },1000)
}
Swiper.prototype.overstop = function(){
    //获取所有li绑定移入事件
    // let liObj = this.el.querySelectorAll('ul li')
    this.page.forEach((item,i) => {
        item.onmouseover = ()=>{
            //清除定时器
            // clearInterval(this.t)
            clearInterval(this.t)
            // 重置num
            
            //换成当前图
            // console.log(img)
            this.el.querySelector('img').src = `./imgs/img${i+1}.jpg`
            this.num = i+1
            //重置分页器
             //同步圆圈
            //将带有圆圈的active去掉
            this.el.querySelector('ul li.active').className = ''
            //给所有li添加active属性
            this.el.querySelectorAll('ul li')[this.num-1].className = 'active'
        }
            this.overmove()
    });
}
Swiper.prototype.overmove = function(){
    this.page.forEach((item,i) => {
        item.onmouseout = ()=>{
            this.changeimg()
        }
    });
    
}